<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>学生通告页面</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <center>
        <el-button type="primary" plain @click="myself">宿舍人员信息</el-button>
        <el-button type="primary" plain @click="leaves">请假</el-button>
        <el-button type="primary" plain @click="helperCheck">去查寝</el-button>
        <el-button type="primary" plain @click="checkDorm">我的查寝信息</el-button>
        <el-button type="primary" plain @click="checknotice">查看通告</el-button>
        <el-button type="danger" plain @click="tc">退出登陆</el-button>

    </center>
    <center>
        <el-table

                :data="tableData"
                style="width: 50%">
            <el-table-column
                    prop="id"
                    label="编号"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="message"
                    label="公告"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="updateTime"
                    label="创建时间"
                    width="180">
            </el-table-column>
            <el-table-column label="操作">

            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="pagination.currentPage"
                    :page-sizes="[2, 5, 10, 15]"
                    :page-size="pagination.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pagination.total">
            </el-pagination>
        </div>
    </center>




</div>

</body>

<!-- 引入组件库 -->

<script src="../js/vue.js"></script>

<script src="../plugins/elementui/index.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

<script src="../js/axios-0.18.0.js"></script>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            tableData: [],
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize:2,//每页显示的记录数
                total:0,//总记录数
            },
            formLabelWidth: '120px',
        },


        mounted() {
            this.queryBoards();
        },

        methods: {


            queryBoards() {
                axios.get('http://127.0.0.1:80/board/queryBoards',{
                    params:{
                        pageNum: this.pagination.currentPage,
                        pageSize: this.pagination.pageSize,
                    }
                }).then(res => {
                    this.tableData=res.data.data.records;
                    this.pagination.total=res.data.data.total
                    console.log(this.tableData);
                });
            },


        handleCurrentChange(val){
            this.pagination.currentPage=val;
            this. queryBoards();
        },
        handleSizeChange(val){
            this.pagination.pageSize=val;
            this. queryBoards();
        },
            tc() {
                this.$confirm("确定退出账户？","提示",{type:"info"}).then(()=>{
                    axios.post("http://localhost/logout").then((res)=>{
                        window.location.href = '/xu/pages/studentLogin.html'
                    })
                })
            },
            cancel(){
                this.dialogFormVisible4Edit=false;
            },
            leaves(){
                window.location.href="http://localhost:80/wu/pages/studentLeave.html"
            },
            myself(){
                window.location.href="http://localhost:80/xu/pages/myself.html"
            },
            checknotice(){
                window.location.href="http://localhost:80/xu/pages/stuboard.html"
            },
            checkDorm(){
                window.location.href="http://localhost:80/wu/pages/studentCheckDorm.html"
            },
            helperCheck(){
                window.location.href="http://localhost:80/wu/pages/helperCheck.html"
            }

        }
    })

</script>

</html>